Repository navigation
fix(cuda.core): pickle Device by UUID - #3198
Conversation
A DeviceMemoryResource sent through multiprocessing, and a pickled VirtualMemoryResource, named their device by ordinal, and the VirtualMemoryResource also sent its peers as ordinals. Ordinals are per process, so a receiver with a different CUDA_VISIBLE_DEVICES rebuilt the resource on the wrong GPU or granted peer access to the wrong GPU. Send the owner and the peers by UUID and map them back in the receiver with a new private helper. Raise a clear RuntimeError when no visible device has the UUID. The tests reverse the device order in the child through CUDA_VISIBLE_DEVICES and check the imported buffer's device UUID. Closes NVIDIA#3097 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The check-cython-not-none hook from main requires it on a def parameter annotated with a cdef class. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ce-uuid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A generator in `peers` was consumed by the first allocation. Later allocations granted no peer access, and a pickled resource sent no peer UUIDs, so the receiver mapped the memory without peer access. `__post_init__` now converts `peers` to a tuple, which also covers options given as a dict, through `replace()`, or per call to `modify_allocation()`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Device.__reduce__ sent the ordinal, so a process with a different CUDA_VISIBLE_DEVICES unpickled a different GPU. It now sends the UUID, and the receiver maps it back with _device_from_uuid(), which raises RuntimeError when the device is not visible. Closes NVIDIA#3196. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uuid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Priority: ➖ Normal Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: NVIDIA/cuda-python
- Branch: main
- File: .coderabbit.yaml
- Commit: afa6249
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Enterprise
- Run ID:
6c0f850a-0fcc-4f2e-abda-c0c16ee5a016
📒 Files selected for processing: 10
cuda_core/cuda/core/_device.pyicuda_core/cuda/core/_device.pyxcuda_core/cuda/core/_memory/_device_memory_resource.pyicuda_core/cuda/core/_memory/_device_memory_resource.pyxcuda_core/cuda/core/_memory/_virtual_memory_resource.pyicuda_core/cuda/core/_memory/_virtual_memory_resource.pyxcuda_core/docs/source/release/1.3.0-notes.rstcuda_core/tests/memory_ipc/test_device_uuid.pycuda_core/tests/test_device.pycuda_core/tests/test_memory.py
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.
|
NVIDIA#3126 merged as d5f37e0 (squash). Keep the Device additions in test_device_uuid.py and the NVIDIA#3196 release-note entry. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments: 1
cuda_core/tests/memory_ipc/test_device_uuid.py: 1
143-143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winsuggestion: Assert the missing UUID without fixing the error wording.
If the error wording changes, this assertion fails even when the
RuntimeErrorstill namesdev0.uuid. Assert that the message containsdev0.uuidinstead. As per coding guidelines: “Avoid asserting on internal call counts, private helper invocation order, or error message substrings that are not part of the contract.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: NVIDIA/cuda-python
- Branch: main
- File: .coderabbit.yaml
- Commit: d5f37e0
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Enterprise
- Run ID:
ce6ee340-a832-47e2-9455-2202f7dd0ff7
📒 Files selected for processing: 2
cuda_core/docs/source/release/1.3.0-notes.rstcuda_core/tests/memory_ipc/test_device_uuid.py
🚧 Files skipped from review as they are similar to previous changes: 1
- cuda_core/docs/source/release/1.3.0-notes.rst
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
…resources on every path - The Device docstring and the release note say the pickled form is for processes on the same machine (asked on NVIDIA#3196). - The buffer tests in test_device_uuid.py release their buffers and pools in finally blocks, so a failed assertion cannot leave an owned pool open for the next test's leak check (CodeRabbit on NVIDIA#3198). - The module docstring cites NVIDIA#3196 for the Device requirement. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Summary
A pickled
Devicenamed its device by ordinal, so a process with a differentCUDA_VISIBLE_DEVICESunpickled it as a different GPU.Device.__reduce__now sends the UUID, and the receiver maps it back with_device_from_uuid()from #3126. Unpickling raisesRuntimeError, naming the UUID and the visible devices, when the device is not visible.Changes
_device.pyx:Device.__reduce__returns(_device_from_uuid, (uuid,)). The class docstring describes the pickled form.Related Work
Closes #3196. Built on #3126 (merged 2026-10-23), which added
_device_from_uuid().🤖 Generated with Claude Code